import { TelegramToken, TgLoginResModel } from "./tg-model";
import { tgSdk } from "./tg-sdk";

declare global {
  interface Window {
    Telegram: any;
  }
}

const ids: TelegramToken = {
  bot_id: "6971488685",
  request_access: "AAG764CHdfhRj8mq9KGWZFAvaHYJ7eBvL3s",
  embed: 1,
};

const login = (): Promise<Partial<TgLoginResModel>> => {
  return new Promise<Partial<TgLoginResModel>>((resolve, reject) => {
    window.Telegram.Login.auth(ids, (data: any) => {
      if (!data) {
        reject(data);
      }
      resolve(data);
    });
  });
};

const logOut = () => {
  console.log("我退出了");
};

export default { login, logOut, tgSdk };
